<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;


    public function parameterError($message = '参数错误'): JsonResponse
    {
        return response()->json(['level'=>'error','message'=>$message,'data'=>null]);
    }
    public function dataError($message = '数据不存在'): JsonResponse
    {
        return response()->json(['level'=>'error','message'=>$message,'data'=>null]);
    }
    public function errorResponse($message = '操作失败'): JsonResponse
    {
        return response()->json(['level'=>'error','message'=>$message,'data'=>null]);
    }
    public function successResponse($message = '操作成功',$data = null): JsonResponse
    {
        return response()->json(['level'=>'success','message'=>$message,'data'=>$data]);
    }
}
